<?php

require_once 'include.php';

switch ($_GET['action'])
{
  case 'listUser':
    echo '<table border="2">';
    foreach(User::getAllUsers() as $user) {
      /* @var $user User */
      echo '<tr>';
      echo '<td>' . $user->getUsername() . '</td>';
      echo '<td>' . $user->getCreatedAt() . '</td>';
      echo '<td><a href="?action=showUser&username=' . $user->getUsername() . '">show</a></td>';
      echo '</tr>';
    }
    echo '</table>';
  case 'showUser':
    $username = $_GET['username'];
    foreach(User::getAllUsers() as $user) {
      if($user->getUsername() == $username) {
        echo '<h1>' . $username . '</h1>';
      }
    }
    break;
}